﻿using UnityEngine;
using System.Collections;

/// <summary>  
/// 平台控制器  
/// </summary>  
public class PlatformController : MonoBehaviour
{
    protected TouchCallback.Begin beginCallback;
    protected TouchCallback.Move moveCallback;
    protected TouchCallback.Scale scaleCallback;
    protected TouchCallback.Update updateCallback;
    protected TouchCallback.End endCallback;
    protected TouchCallback.EndScale endScaleCallback;
    protected TouchCallback.Multi2One multi2OneCallback;
    protected TouchCallback.BeginScale beginScaleCallback;

    protected Camera ctrlCamera;

    /// <summary>  
    /// 初始化回调函数  
    /// </summary>  
    /// <param name="beginCallback">Begin callback.</param>  
    /// <param name="moveCallback">Move callback.</param>  
    /// <param name="scaleCallback">Scale callback.</param>  
    /// <param name="updateCallback">Update callback.</param>  
    /// <param name="endCallback">End callback.</param>  
    public virtual void Init(
        TouchCallback.Begin beginCallback, 
        TouchCallback.Move moveCallback, 
        TouchCallback.Scale scaleCallback, 
        TouchCallback.Update updateCallback,
        TouchCallback.End endCallback,
        TouchCallback.EndScale endScaleCallback,
        TouchCallback.Multi2One multi2OneCallback,
        TouchCallback.BeginScale beginScaleCallback,
        Camera ctrlCamera)
    {
        this.beginCallback = beginCallback;
        this.moveCallback = moveCallback;
        this.scaleCallback = scaleCallback;
        this.updateCallback = updateCallback;
        this.endCallback = endCallback;
        this.endScaleCallback = endScaleCallback;
        this.multi2OneCallback = multi2OneCallback;
        this.beginScaleCallback = beginScaleCallback;
        this.ctrlCamera = ctrlCamera;
    }

    protected Vector2 GetViewPortPos(Vector2 pos)
    {
        if (ctrlCamera != null)
        {
            return ctrlCamera.ScreenToViewportPoint(pos);
        }

        return Vector2.zero;
    }
}
